package com.netease.controller;

import com.netease.config.FlyBookConfig;
import com.netease.config.YouDaoConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @projectName: modeling-dev
 * @package: com.netease.controller
 * @className: MyController
 * @author: aochong
 * @description: TODO
 * @date: 2023/4/24 15:48
 * @version: 1.0
 */
@RestController
@RequestMapping("myController")
@Api(value = "测试接口", tags = {"自定义测试相关接口"})
@EnableConfigurationProperties(FlyBookConfig.class) //应用配置文件类，使RemoteProperties注解类生效
public class MyController {

    @Autowired
    private FlyBookConfig flyBookConfig;

    @Autowired
    private YouDaoConfig youDaoConfig;

    @GetMapping("/test")
    @ApiOperation(value = "读取配置文件内容", notes = "读取配置文件内容", httpMethod = "GET")
    public String test(){
        return flyBookConfig.getApp_id() + "," + flyBookConfig.getApp_secret();
    }

    @GetMapping("/test1")
    @ApiOperation(value = "读取配置文件内容", notes = "读取配置文件内容", httpMethod = "GET")
    public String test1(){
        return youDaoConfig.getUrl() + "," + youDaoConfig.getApp_key() + "," + youDaoConfig.getApp_secret();
    }
}
